package com.init.bootframe.system.controller;

import com.init.bootframe.system.service.IBaseDataService;
import com.init.bootframe.system.vo.BaseDataVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/baseData")
public class BaseDataController {

    private Logger logger = LoggerFactory.getLogger(RoleController.class); // 日志

    @Autowired
    private IBaseDataService baseDataService; //基础数据service

    /**
     * 根据条件查询基础数据信息
     * @param baseDataVO
     * @return
     * @throws Exception
     */
    @PostMapping("/findBaseDataListByCode")
    public List<BaseDataVO> findBaseDataListByCode(@RequestBody BaseDataVO baseDataVO) throws Exception {
        List<BaseDataVO> result = baseDataService.findBaseDataListByCode(baseDataVO);
        return result;
    }

    /**
     * 查询基础数据信息
     * @param baseDataVO
     * @return
     */
    @PostMapping("/findBaseDataList")
    public Map<String, Object> findBaseDataList(@RequestBody BaseDataVO baseDataVO) {
        Map<String, Object> result = baseDataService.findBaseDataList(baseDataVO);
        return result;
    }

    /**
     * 添加基础数据
     * @param baseDataVO
     * @return
     */
    @PostMapping("/addBaseData")
    public Map<String, Object> addBaseData(@RequestBody BaseDataVO baseDataVO) {
        Map<String, Object> result = baseDataService.addBaseData(baseDataVO);
        return result;
    }

    /**
     * 修改基础数据
     * @param baseDataVO
     * @return
     */
    @PostMapping("/updateBaseData")
    public Map<String, Object> updateBaseData(@RequestBody BaseDataVO baseDataVO) {
        Map<String, Object> result = baseDataService.updateBaseData(baseDataVO);
        return result;
    }

    /**
     * 删除基础数据
     * @param baseDataVO
     * @return
     */
    @PostMapping("/deleteBaseData")
    public Map<String, Object> deleteBaseData(@RequestBody BaseDataVO baseDataVO) {
        Map<String, Object> result = baseDataService.deleteBaseData(baseDataVO);
        return result;
    }

    /**
     * 根据baseId查询基础数据信息
     * @param baseDataVO
     * @return
     */
    @PostMapping("/findBaseDataInfo")
    public BaseDataVO findBaseDataInfo(@RequestBody BaseDataVO baseDataVO) {
        BaseDataVO result = baseDataService.findBaseDataInfo(baseDataVO);
        return result;
    }




}
